package com.jk.demo.service;

import com.jk.demo.dao.EsDao;
import com.jk.demo.dao.ProductDao;
import com.jk.demo.entity.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EsService {
    @Autowired
    private EsDao esDao;
    @Autowired
    private ElasticsearchTemplate elasticsearchTemplate;
    @Autowired
    private ProductDao productDao;


    public void tong() {
        List<Product> listPros = productDao.getListPros();
        for (int i = 0; i <listPros.size() ; i++) {
            esDao.save(listPros.get(i));
        }
    }
}
